package com.dlc.shop.systemtest.api.order;


import com.dlc.shop.bean.app.dto.ApiOrderRefundDto;
import com.dlc.shop.bean.app.param.OrderRefundExpressParam;
import com.dlc.shop.bean.app.param.OrderRefundParam;
import com.dlc.shop.bean.model.OrderRefund;
import com.dlc.shop.systemtest.constants.Constant;
import com.dlc.shop.systemtest.util.HttpUtil;

import java.util.Objects;

/**
 * @author lanhai
 */
public class OrderRefundApi {
    /**
     * 申请退款
     * @param orderRefundParam
     * @return
     */
    public static String apply(OrderRefundParam orderRefundParam){
        String url = Constant.API_URL+"/p/orderRefund/apply";
        return HttpUtil.post(url,orderRefundParam,String.class,true);
    }


    /**
     * 根据退款编号获取退款信息
     * @param refundSn
     * @return
     */
    public static OrderRefund infoByRefundSn (String refundSn, Long shopId) {
        String url = Constant.SHOP_URL+"/order/refund/infoByRefundSn?refundSn="+refundSn;
        return HttpUtil.get(url,OrderRefund.class, Objects.equals(shopId, 1L) ? true : false);
    }

    public static OrderRefund infoByRefundSn (String refundSn) {
        String url = Constant.SHOP_URL+"/order/refund/infoByRefundSn?refundSn="+refundSn;
        return HttpUtil.get(url,OrderRefund.class);
    }


    /**
     * 用户提交退款订单物流填写信息
     * @param orderRefundExpressParam
     */
    public static void submitExpress(OrderRefundExpressParam orderRefundExpressParam){
        String url = Constant.API_URL+"/p/orderRefund/submitExpress";
        HttpUtil.post(url, orderRefundExpressParam);
    }

    public static ApiOrderRefundDto infoUserByRefundSn(String refundSn){
        String url = Constant.API_URL+"/p/orderRefund/info?refundSn="+refundSn;
        return HttpUtil.get(url,ApiOrderRefundDto.class);
    }

    public static void cancel(String refundSn){
        String url = Constant.API_URL+"/p/orderRefund/cancel";
        HttpUtil.put(url,refundSn);
    }
}
